package com.albaba.designpattern.command.text_001;

import java.util.Set;

/**
 * @Description: TODO
 * @Author zx
 * @Date 2025/2/27 17:05
 * @Version 1.0
 */
public class OrderCommand implements Command {

    // 持有者对象引用
    private Chef receiver;

    private Order order;

    public OrderCommand(Chef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable() + "号桌的订单");

        Set<String> keySet = order.getFoodMenu().keySet();

        for (String key : keySet) {
            receiver.makeFood(order.getFoodMenu().get(key), key);
        }
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        System.out.println(order.getDiningTable() + "号桌的订单已经完成");
    }
}
